<?php defined('IN_IA') or exit('Access Denied');?><?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('public/header', TEMPLATE_INCLUDEPATH)) : (include template('public/header', TEMPLATE_INCLUDEPATH));?>

<?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('public/comhead', TEMPLATE_INCLUDEPATH)) : (include template('public/comhead', TEMPLATE_INCLUDEPATH));?>
<link rel="stylesheet" type="text/css" href="../addons/yzzc_sun/template/public/ygcsslist.css">
<ul class="nav nav-tabs">
    <span class="ygxian"></span>
    <div class="ygdangq">当前位置:</div>
    <li class="active" ><a >首页弹窗广告列表</a></li>
</ul>

<div class="main">
    <br>
    <div class="form-group">
        <label for="lastn" class="col-sm-2 control-label">是否开启首页弹窗广告</label>
        <div class="col-sm-10">
            <label class="radio-inline">
                <input onchange="check(this)" type="radio" id="emailwy3" name="open" value="1" <?php  if($info['open']>0) { ?>checked<?php  } ?> />
                <label for="emailwy3">开启</label>
            </label>
            <label class="radio-inline">
                <input onchange="check(this)" type="radio" id="emailwy" name="open" value="0" <?php  if($info['open']==0) { ?>checked<?php  } ?> />
                <label for="emailwy">关闭</label>
            </label>
            <div class="help-block">*是否开启首页弹窗，关闭进入小程序时则不显示弹窗广告</div>
        </div>
    </div>
    <br>
    <br>
    <br>
    <div class="panel-heading wyheader">
        <a href="<?php  echo $this->createWebUrl('adpic')?>" class="storespan2 btn btn-xs" style="left: 15px;background-color: #444444;color: #fff;border-color: #444444;">
            <span class="fa fa-plus"></span>添加首页弹窗广告
            <span class="bianji" style="left: 15px;background-color: #444444;color: #fff;border-color: #444444;">
                        <span class="arrowdown"></span>
                    </span>
        </a>
    </div>
    <div class="panel panel-default">
        <div class="panel-heading">
            首页弹窗广告列表
        </div>
        <div class="panel-body" style="padding: 0px 15px;">
            <div class="row">
                <table class="yg5_tabel col-md-12">
                    <tr class="yg5_tr1">
                        <!--<td class="store_td1 col-md-1"></td>-->
                        <td class="col-md-1">弹窗标题</td>
                        <!--<td class="col-md-1">弹窗图片</td>-->
                        <td class="col-md-2">弹窗链接类型</td>
                        <td class="col-md-1">链接id</td>
                        <td class="col-md-1">排序</td>
                        <td class="col-md-2">操作</td>
                    </tr>
                    <?php  if(is_array($list)) { foreach($list as $key => $item) { ?>
                    <tr class="yg5_tr2">
                        <td><?php  echo $item['title'];?></td>
                        <!--<td><img src="<?php  echo $item['ad_pic'];?>" style="width: 50px"></td>-->
                        <td><?php  if($item['link_type']==0) { ?>无链接
                            <?php  } else if($item['link_type']==1) { ?> 车型
                            <?php  } else if($item['link_type']==2) { ?> 门店
                            <?php  } else if($item['link_type']==3) { ?> 活动
                            <?php  } ?>
                        </td>
                        <td><?php  echo $item['link_typeid'];?></td>
                        <td><?php  echo $item['sort'];?></td>
                        <td>
                            <a href="<?php  echo $this->createWebUrl('adpic',array('id'=>$item['id']));?>" class="storespan btn btn-xs">
                                <span class="fa fa-pencil"></span>
                                <span class="bianji">编辑
                                    <span class="arrowdown"></span>
                                </span>
                            </a>
                            <a href="javascript:void(0);" class="storespan btn btn-xs" data-toggle="modal" data-target="#myModal<?php  echo $item['aid'];?>">
                                <span class="fa fa-trash-o"></span>
                                <span class="bianji">删除
                                    <span class="arrowdown"></span>
                                </span>
                            </a>

                            <!-- <a href="<?php  echo $this->createWebUrl('activeinfo',array('id'=>$item['id']));?>"><button class="btn btn-success btn-xs">查看</button></a>
                           <button type="button" class="btn btn-danger btn-xs" data-toggle="modal" data-target="#myModal<?php  echo $item['id'];?>">删</button> -->
                        </td>

                    </tr>
                    <div class="modal fade" id="myModal<?php  echo $item['aid'];?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                        <div class="modal-dialog" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                    <h4 class="modal-title" id="myModalLabel" style="font-size: 20px;">提示</h4>
                                </div>
                                <div class="modal-body" style="font-size: 20px">
                                    确定删除么？
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                    <a href="<?php  echo $this->createWebUrl('adpic', array('op' => 'delete', 'id' => $item['id']))?>" type="button" class="btn btn-info" >确定</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php  } } ?>
                    <?php  if(empty($list)) { ?>
                    <tr class="yg5_tr2">
                        <td colspan="8">
                            暂无活动信息
                        </td>
                    </tr>
                    <?php  } ?>
                </table>
            </div>
        </div>
    </div>
</div>
<div class="text-right we7-margin-top">
    <?php  echo $pager;?>
</div>
<script type="text/javascript">
    $(function(){
        $("#frame-12").show();
        $("#yframe-12").addClass("wyactive");
        // ———————————————批量删除———————————————
        $("#allselect").on('click',function(){
            var check = $("input[type=checkbox][class!=allcheck]:checked");
            if(check.length < 1){
                alert('请选择要删除的商品!');
                return false;
            }else if(confirm("确认要删除此商品?")){
                var id = new Array();
                check.each(function(i){
                    id[i] = $(this).val();
                });

                $.ajax({
                    type:"post",
                    url:"<?php  echo $_W['siteroot'];?>/app/index.php?i=<?php  echo $_W['uniacid'];?>&c=entry&do=Deleteactive&m=yzzc_sun",
                    dataType:"text",
                    data:{id:id},
                    success:function(data){
                        console.log(data);
                        location.reload();
                    }
                })

            }
        });
    })
    //开启关闭
    function check() {
        var open= $('input[name="open"]:checked').val();
        $.ajax({
            type:"POST",
            url:"<?php  echo $this->createWebUrl('adpic_list',array('op'=>delete))?>",
            dataType:"JSON",
            data:{open:open},
            success:function(res){
                console.log(res);
                location.reload();
            }
        })
    }
</script>